@extends('admin.layout.layout', ['row' => @$page])

@section('contain')
    <style>
        .dhlx-box{
            /*width: 800px;*/
        }
        .dhlx-box .title{
            text-align: center;
        }
        .dhlx-box .title b{
            display: inline-block;
            background-color: #dcdfe6;
            font-weight: normal;
            font-size: 1.25rem;
            padding: .5rem 2rem;
            line-height: 1rem;
        }
        .dhlx-box .dhlx-body{
            display: flex;
            flex-wrap: nowrap;
            border: 1px solid #ebeef5;
        }
        .dhlx-box .dhlx-body .ygms{
            flex: 0 0 50%;
            padding: 25px;
            box-sizing: border-box;
            border-right: 1px solid #ebeef5;
        }
        .dhlx-box .dhlx-body .xgms{
            flex: 0 0 50%;
            padding: 25px;
            box-sizing: border-box;
            border-left: 1px solid #ebeef5;
        }
        .table .tth{
            background-color: rgba(0, 0, 0, 0.05);
            width: 150px;
            font-weight: bold;
        }
        .table .ttd{
            width: 350px;
        }
        .table .tst{
            color: #1e89e0;
            font-weight: 700;
            text-align: center;
            font-size: 1.25rem;
        }
    </style>

    <div class="portlet">
        <div class="portlet-title">
            <div class="caption">
                <x-portlet-breadcrumb :page="$page"></x-portlet-breadcrumb>
            </div>
            <div class="actions"></div>
        </div>

        <div class="my-3 bg-light p-3 px-4">
            <div class="row">
                <div class="col-auto">
                    <b>套件ID</b>：
                    <span>{{ $data->precut_id ?? '' }}</span>
                </div>

                <div class="col-auto">
                    <b>{{ ts('createdat') }}</b>：
                    <span>{{ fdate(@$data->created_at) }}</span>
                </div>
            </div>
        </div>

        <div class="dhlx-box">
            <table class="table table-bordered">
                <tbody>
                <tr>
                    <td colspan="4" class="tst">{{ ts('DHLX') }}</td>
                </tr>
                <tr>
                    <td class="tth">{{ ts('DHFQSD') }}</td>
                    <td class="ttd">
                        @if($data->ygms_ut == 3)
                            {{ $data->ysd }}
                        @else
                            {{ $data->ygmsmc }}
                        @endif
                    </td>
                    <td class="tth">{{ ts('DHSD') }}</td>
                    <td class="ttd">
                        @if($data->xgms_ut == 3)
                            {{ $data->xsd }}
                        @else
                            {{ $data->xgmsmc }}
                        @endif
                    </td>
                </tr>
                <tr>
                    <td class="tth">{{ ts('DHFQJXS') }}</td>
                    <td class="ttd">
                        @if($data->ygms_ut == 3)
                            {{ $data->ygmsmc }}
                        @else
                            {{--{{ $data->ygmsmc }}--}}
                        @endif
                    </td>
                    <td class="tth">{{ ts('DHJXS') }}</td>
                    <td class="ttd" class="">
                        @if($data->xgms_ut == 3)
                            {{ $data->xgmsmc }}
                        @else
                            {{--{{ $data->xgmsmc }}--}}
                        @endif
                    </td>
                </tr>
                <tr>
                    <td colspan="4" class="tst">{{ ts('DHYY') }}</td>
                </tr>
                <tr>
                    <td colspan="4">{{ $data->note }}</td>
                </tr>
                </tbody>
            </table>
        </div>
        @if($data->approved == 0 && session('admin.user_type') == 1)
            <div class="my-3">
                <button class="btn btn-primary mr-5" onclick="verifyTransfer(1)">{{ ts('TY') }}</button>
                <button class="btn btn-danger ml-5" onclick="verifyTransfer(2)">{{ ts('JJ') }}</button>
            </div>
        @else
            <div class="my-3">
                {{ ts('status') }}：{{ ts('STA'.$data->approved) }}
            </div>
        @endif

    </div>



@endsection

@section('script')
    <script>
        function verifyTransfer(verify) {
            var url = '/{{ request()->path() }}/verify';
            if (verify == 1) {
                act = '同意';
            }  else {
                act = '拒绝';
            }
            var msg = '确认' + act + '从 {{ $data->ygmsmc }} 调货至 {{ $data->xgmsmc }} ？';
            mySwal(msg)
                .then(function (d) {
                    request.post(url, {
                        verify: verify
                    })
                        .then(function (d) {
                            mySwal2()
                        })
                        .catch(function (d) {
                            sw3(d.msg, 'error');
                        })
                })
                .catch(function (d) {
                    console.log(d)
                });

            console.log(verify)
        }
    </script>
@endsection